package com.easy.query.test.vo;


import com.easy.query.core.expression.parser.core.extra.ExtraAutoIncludeConfigure;
import com.easy.query.core.proxy.sql.Select;
import com.easy.query.test.entity.blogtest.proxy.SysRoleProxy;
import lombok.Data;
import com.easy.query.core.annotation.Column;
import com.easy.query.core.annotation.Navigate;
import com.easy.query.core.enums.RelationTypeEnum;

import java.util.List;
import java.time.LocalDateTime;

import lombok.Data;

/**
 * this file automatically generated by easy-query struct dto mapping
 * 当前文件是easy-query自动生成的 结构化dto 映射
 * {@link com.easy.query.test.entity.blogtest.SysUser }
 *
 * @author xuejiaming
 * @easy-query-dto schema: normal
 */
@Data
public class SysUserRoleMenuDTO {


    private String id;
    private String companyId;
    private String name;
    private Integer age;
    private LocalDateTime createTime;
    @Navigate(value = RelationTypeEnum.ManyToMany)
    private List<InternalRoles> roles;


    /**
     * {@link com.easy.query.test.entity.blogtest.SysRole }
     */
    @Data
    public static class InternalRoles {


        private static final ExtraAutoIncludeConfigure EXTRA_AUTO_INCLUDE_CONFIGURE = SysRoleProxy.TABLE.EXTRA_AUTO_INCLUDE_CONFIGURE()
                .where(o->o.name().like("管理员"))
                .select(o -> Select.of(
                        o.menus().where(menu->menu.route().startsWith("/api/app/")).elements(0,2).joining(menu->menu.name(),",").as("top3Menus"),
                        o.menus().where(menu->menu.route().startsWith("/api/web/")).count().as("menuCount")
                ));

        private String id;
        private String name;
        private LocalDateTime createTime;

        private String top3Menus;
        private Long menuCount;

    }

}
